<?php
header('Content-type: image/jpg');
$img = $_GET['img'];
$url = base64_decode($img);

//print_r(array($url,$img));
if(is_file("images/cache/$img"))
{
    readfile("images/cache/$img");
}
else
{
    $image = @file_get_contents($url);
    if(strlen($image)<=25000)
    {
        file_put_contents("images/cache/$img", $image);
        readfile("images/cache/$img");
    }
    else echo $image;
}
?>